import React, { FC, useEffect, useState } from 'react'
import {addPlanlist } from "@/services"
/* import './addplan.less' */
import 'moment/locale/zh-cn';
import { observer } from 'mobx-react-lite';
import locale from 'antd/es/date-picker/locale/zh_CN';
import {Form,Input,DatePicker,InputNumber,Select,Button  } from 'antd';

/* function finshi(value:any){
  let {}
}
 */
const AddPlan:FC=()=>{

  const { Option } = Select;
  const { RangePicker } = DatePicker;
  const [carindex, setcarindex] = useState('成员数')
  function setnameList(){
    addPlanlist().then(res=>{
      setcarindex(res.data.length)
    })
  }
  const onFinish = (value:any)=>{
    function add0(m:any){
      return m<10?'0'+m:m 
    }
    function format(shijianchuo:any)
    {
      var time = new Date(shijianchuo);
      var y = time.getFullYear();
      var m = time.getMonth()+1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
    }
    let a = format(value.time[0]._d)
    let b = format(value.time[1]._d)

    console.log(value)
  }
  return (
    <div className='addplan'>
      <div className='totaltitle'>
          
      </div>
      <div className='subtitle'>
        <div className='title_type1'>
            <div className='title_son'>
                <span className='title_span'></span>
                <div className='title_theme'>添加计划</div>
            </div>
        </div>
        <div className='title_type2'>
          <Form 
           onFinish={onFinish} >
            <div className='title_cascader '>
              <Form.Item label='班级' name='classname'>
                <Select defaultValue="请选择班级" style={{ width: 120 }} 
                 onChange={setnameList} >
                  <Option type='classname' value="网站2021A班">网站2021A班</Option>
                </Select>
              </Form.Item>
              <Form.Item label='成员' name='username'>
                  <Input type='username' placeholder={carindex} disabled={true} />
              </Form.Item>
              <Form.Item label='分组' name='zhu' >
                  <InputNumber type='zhu' min={1} max={10} defaultValue={1} />
              </Form.Item>
            </div>
            <div className='title_input'>
              <Form.Item label='计划' name='planname' >
                  <Input type='planname' placeholder="请输入计划"  />
              </Form.Item>
            </div>
            <div className='title_time'>
              <Form.Item label='日期' name='time'>
                <RangePicker  locale={locale}  />
              </Form.Item>
            </div>
            <div className="item__content" >
              <Button className='sl_button'>
                <span>
                  自动分组
                </span>
              </Button>
              <Button className='sl_button' type="primary" htmlType="submit">
                <span>
                  手动分组
                </span>
              </Button>
            </div>
          </Form>
        </div>
      </div>
    </div>
  )
}
export default observer(AddPlan)